(function($, doc){	
	//dialog ui.
	var _dialogBodyTmp = [
    		'<div class="dialogWrapper">',
    			'<div class="dialogHeader">',
    				'<h2></h2>',
    				'<div class="dialogHeaderToolbar">',
    				    '<span class="fullscreen icon32" title="full screen"></span>',
    				    '<span class="fullscreen_exit icon32" title="exit full screen" style="display:none;"></span>',
    				    '<span class="close icon32" title="close dialog"></span>',
    			    '</div>',
    			'</div>',
    			'<div class="dialogContent">',
        			'<div class="dialogBody"></div>',
        			'<div class="dialogToolbar"></div>',
        			'<div class="dialogMasker hvBox hidden">',                
                        '<span class="dialogProcessingText"></span>',
                    '</div>',
    			'</div>',
    		'</div>'
    	].join(''),    	
    	_defaultConfig = { 
    		width : 550,
    		height : 320, 
    		icon : ujs.getRes('images/common32/dialog.png'),
    		isModal : true,   //是否是模式对话框.
    		toolbar : true
    	},    	
    	_bubbleDefaultConfig = {
	       type : 'tip'
    	},
    	$window = $(window);
	
	//---------------------------------------------------------------------------------------------------------------------
	
	/**
	 * 对话框构造函数. 
	 */
	function _Dialog(config){
		var _this = this;		
		Observable.enable(this);							
		this.config = $.extend({}, _defaultConfig, config);			
		this.$wrapper = $(_dialogBodyTmp);
		
		this.$dialogHeaderToolbar = this.$wrapper.find('.dialogHeaderToolbar');
        this.$dialogToolbar = this.$wrapper.find('.dialogToolbar');
        this.$dialogContent = this.$wrapper.find('.dialogContent');
        this.$dialogBody = this.$wrapper.find('.dialogBody');
        this.$dialogBody.css(
            'height', 
            'calc(100% - {0}px)'.format(this.config['toolbar'] === false ? 20 : 60)
        );

		//不可选择文本.
		this.$wrapper.addClass('unselectable');		
		//使可以移动.
		this.$wrapper.addClass('movable');
		this.$wrapper.movable({
		    proxy : this.$wrapper.find('.dialogHeader')
		});		
		//使可以调整大小.
		if(this.config['resizable'] !== false){
    		this.$wrapper.addClass('resizable');
    		this.$wrapper.resizable();
        } else {
            this.$dialogHeaderToolbar.find('.fullscreen, .fullscreen_exit').hide();    
        }
        
        // ujs.browser.evt.onResizend(function(){
            // _this.setWidth( $window.width() - 20 );
            // _this.setHeight( $window.height() - 20 );
            // _this.resetDialogPosition(); 
        // });
					
	    this.$dialogBody.style(this.config['bodyStyle']);				
		this.setIcon( this.config['icon'] );
		this.setTitle( this.config['title'] );
		
        //全屏/退出全屏
        this.on('fullscreen', function(){
            _this.$dialogHeaderToolbar.find('.fullscreen').hide();
            _this.$dialogHeaderToolbar.find('.fullscreen_exit').show();
            _this._isFullscreen = true;
        });        
        this.on('fullscreenExit', function(){
            _this.$dialogHeaderToolbar.find('.fullscreen_exit').hide();
            _this.$dialogHeaderToolbar.find('.fullscreen').show();
            _this._isFullscreen = false;
        });
        this.$wrapper.delegate('.fullscreen', 'click', function(e){
            _this.fullscreen();   
        });
        this.$wrapper.delegate('.fullscreen_exit', 'click', function(e){            
            _this.exitFullscreen();      
        });
        
        //尺寸.
        if(!this.config['width']){ this.config['width'] = $window.width() / 2; }
        if(!this.config['height']){ this.config['height'] = $window.height() / 2; }                
        if(this.config['isFullscreen'] === true){
            _this.fullscreen(false);            
        } else {
            this.setWidth( this.config['width'] );
            this.setHeight( this.config['height'] );
        } 
			
		//工具条按钮.	
		if(this.config['buttons']){
			this.addDialogButton(this.config['buttons']);
		}
				
		if(this.config['url']){
		    //若使用指定的url初始化对话框内容.
		    this.addDialogContent([
		        '<div class="card url">',
	                '<iframe style="width: 100%;height: calc(100% - 4px);" src="{0}"><iframe>',
                '</div>'
            ].join('').format(this.config['url']));
            //iframe的onload事件注册.
                    
            this.$wrapper.find("iframe").load(function (){
            	if(Type.isFunction(_this.config['onUrlLoad'])){
                	_this.config['onUrlLoad'](this);
               }
               _this.hideMask(); 
            });
            _this.showMask();    
		} else {
		    //指定对话框内容初始化的html片段.
            if(this.config['html']){
                this.addDialogContent(this.config['html']);
            }    
		}				
		
		//关闭.	
		this.$wrapper.delegate('.close', 'click', function(e){			
			_this.close();					
		});
		if(_this.config['closable'] === false){
            _this.$dialogHeaderToolbar.find('.close').hide();
        }
        
        this.on(this.config['events']);
        this.$wrapper.appendTo(doc.body);        
	}
	
	//---------------------------------------------------------------------------------------------------------------------
	
	/**
	 * 显示对话框.
	 */
	_Dialog.prototype.show = function(){
	    var _this = this;
	    _Dialog.current = this;	    
		this.resetDialogPosition(function(){		    
            this.$wrapper.css({
                left : this.left + 'px',
                top : -this.$wrapper.height(),
                opacity : 0
            }).show().animate({         
                top : this.top + 'px',
                opacity : 1
            }, 300, 'easeInQuart', function(){
                ujs.ui.paneMask.show();                
                (function(){
                    //Dialog呈现完成后.
                    _this.fire('inital');
                }).defer(0);
            }).focus();
		});		
		if(this.hasCard()){
		    this.applyCardProps(this.getCurrentCardName());
		}		
		return this;
	};
	
	/**
	 * 重新设置Dialog的位置，水平垂直居中. 
	 */
	_Dialog.prototype.resetDialogPosition = function(fun){
        this.left = Math.max((($window.width() - this.$wrapper.width())/2).toFixed(0), 0);
        this.top = Math.max((($window.height() - this.$wrapper.height())/2).toFixed(0), 0); 
        
        if(Type.isFunction(fun)){
            fun.call(this);
        } else {
            this.$wrapper.css({
                left : this.left,
                top : this.top    
            });
        }
	};
	
	//---------------------------------------------------------------------------------------------------
	
	/**
	 * 全屏对话框。 
	 */
	_Dialog.prototype.fullscreen = function(isAnimated){
	    var _this = this,
            doneHandler = function(){                
                _this.fire('fullscreen');
                _this.fire('fullscreenChanged');      
            },
            resultCSS = {
                left : 10,
                top : 10,
                width : $window.width() - 20,
                height : $window.height() - 20
            };
	    if(Type.isUndefined(isAnimated)){
	        isAnimated = true;
	    }
	    if(isAnimated){
            _this.$wrapper.animate(resultCSS, doneHandler);    
	    } else {
            _this.$wrapper.css(resultCSS);
            doneHandler();
	    }	    
        return _this; 
	};
	
	/**
	 *判断对话框是否在全屏状态. 
	 */
	_Dialog.prototype.isFullscreen = function(){
        return !!this._isFullscreen;
	};
	
	/**
	 * 退出全屏。 
	 */
	_Dialog.prototype.exitFullscreen = function(){
	    var _this = this;
	    _this.$wrapper.animate({
            left : _this.left,
            top : _this.top,
            width : _this.width,
            height : _this.height
        }, function(){            
            _this.fire('fullscreenExit');
            _this.fire('fullscreenChanged');
        });  
        return _this;
	};
	
	//---------------------------------------------------------------------------------------------------
	
	//隐藏对话框.
	_Dialog.prototype.hide = function(){
		this.$wrapper.hide('fast');
		ujs.ui.paneMask.hide();
		_Dialog.current = undefined;
		return this;
	};
	
	//关闭对话框.
	_Dialog.prototype.close = function(){
	    if( this.fireEvent('close') !== false ){
            this.remove();             
        }          	
    	return this;
	};
	
	//---------------------------------------------------------------------------------------------------
	
	/**
     * 清空对话框内容. 
     */
    _Dialog.prototype.clearBody = function(){
        this.$dialogBody.html('');
        return this;
    };
	
	//隐藏并删除对话框.
	_Dialog.prototype.remove = function(){
		var _this = this;     
        this.$wrapper.animate(
            {
                top : -this.$wrapper.outerHeight(),
                opacity: 0.1
            }, 
            200, 
            "linear",
            function(){
                _this.hide();
                _Dialog.current = undefined;  
                _this.$wrapper.remove();  
            }
        );
        return this;
	};

    //---------------------------------------------------------------------------------------------------------------------

	/**
	 * 设置对话框属性. 
	 */
	_Dialog.prototype.setProps = function(props){
	    var _this = this;
	    $.extend(this.config, props);
	    
	    if(props['title']){
	        this.setTitle(props['title']);
	    }
	    if(props['size']){
	        this.setSize(props['size']);
	    }
	    if(props['icon']){
	        this.setIcon(props['icon']);
	    }
	    //卡片布局时,保存卡片布局配置.
	    if(props['cards']){
	        this.config['cards'] = props['cards'];
	    }
	    if(props['buttons']){
	        this.addDialogButton(props['buttons']);   
	    }
	    if(props['bodyStyle']){
	        this.$dialogBody.style(props['bodyStyle']);
	    }
	    if(props['toolbarStyle']){
	        this.$dialogToolbar.style(props['toolbarStyle']);
	    }
	    if(props['isFullscreen']){
	        this.$wrapper.find('.fullscreen, .fullscreen_exit').remove();	            	        
            _this.fullscreen(false);
	    }
	    if(props['events']){
	        this.on(props['events']);
	    }
	    if(!Type.isUndefined(props['toolbar'])){
	        if(props['toolbar']){
	            this.showToolbar();
	        } else {
	            this.hideToolbar();
	        }
	    }
	};
	
	/**
	 * 设置对话框的尺寸。
	 */
	_Dialog.prototype.setSize = function(width, height){	    
	    //兼容setSize({width:1000, height:600});
        if(Type.isObject(width)){
            var size = width;
            width = size['width'];
            height = size['height'];
        }
        this.setWidth(width);
        this.setHeight(height);
	};
	
	//设置对话框宽度.
	_Dialog.prototype.setWidth = function(width){
	    if(width){
    	    width = String(width);
    	    if(width.endsWith('%')){
    	        width = width.toFloat() * $(window).width(); 
    	    } else {
    	        width = parseInt(width);
            }	    
	        this.width = width;
    		this.$wrapper.css('width', width + 'px' );    		
		}
		return this;
	};
	
	//设置对话框高度.
	_Dialog.prototype.setHeight = function(height){	    
	    if(height){
	        height = String(height);
	        if(height.endsWith('%')){
	            height = height.toFloat() * $(window).height();
	        } else {
	            height = parseInt(height);
            }
	        this.height = height;
    		this.$wrapper.css('height', height + 'px');
		}
		return this;
	};
	
	//设置对话框图标。
	_Dialog.prototype.setIcon = function(iconPath){
		if( iconPath ){
		    if(!this.$dialogHeaderIcon){		
    		    this.$dialogHeaderIcon = $('<div class="dialogHeaderIcon" style="background-image:url({0})"></div>'.format(iconPath)); 	
    			this.$wrapper.find('.dialogHeader').prepend(this.$dialogHeaderIcon);
    		} else {
    		    this.$dialogHeaderIcon.css('background-image', 'url({0})'.format(iconPath));
    		}
		}
		return this;
	};
	
	//设置对话框标题.
	_Dialog.prototype.setTitle = function(title){
		if( title ){
			$('.dialogHeader h2', this.$wrapper).text(title);			
		}
		return this;
	};
	
	//---------------------------------------------------------------------------------------------------------------------
	
	//修改对话框的结构.
	_Dialog.prototype.addDialogStructure = function(dialogStructureHtml /*or getDialogStructureFun*/, callback){
		dialogStructureHtml = $.isFunction(dialogStructureHtml) ? dialogStructureHtml.call(this) : dialogStructureHtml;
		if( dialogStructureHtml ){
			var $dialogStructure = $(dialogStructureHtml).appendTo( this.$wrapper );
			lan.parse($dialogStructure);
			callback && callback( $dialogStructure );
 		}
 		return this;
	};
	
	//添加对话框内容.
	_Dialog.prototype.addDialogContent = function(dialogContentHtml, callback, isInitDialogContentBody){
	    //兼容addDialogContent(callback, isInitDialogContentBody)	
	    if(Type.isFunction(dialogContentHtml)){
	        isInitDialogContentBody = callback;
	        callback = dialogContentHtml;
	        dialogContentHtml = '<div></div>';
	    }	
	    
		if(isInitDialogContentBody){
			this.$dialogBody.html('');
		}
		if( dialogContentHtml ){
		    if(this.hasCard()){
		        //卡片布局时，隐藏已有卡片.
		        this.getCards().hide();
		    }
			var $dialogContent = $( dialogContentHtml ).appendTo( this.$dialogBody );			
			lan.parse($dialogContent);
			callback && callback( $dialogContent );
		}
		return this;
	};
	
	//---------------------------------------------------------------------------------------------------------
	
	//添加对话框内容.
    _Dialog.prototype.addDialogLayer = function(dialogLayerID, dialogLayerHtml, callback, $position){ 
        if( dialogLayerHtml ){            
            var $dialogLayer = $(dialogLayerHtml).appendTo( $position || this.$dialogBody );    
            $dialogLayer.addClass('dialogLayer').attr('layer-id', dialogLayerID);       
            lan.parse($dialogLayer);
            callback && callback( $dialogLayer );
        }
        return this;
    };
	
	_Dialog.prototype.getDialogLayer = function(dialogLayerID){
	    return this.$dialogBody.find('.dialogLayer[layer-id={0}]'.format(dialogLayerID));
	};
	
	_Dialog.prototype.removeDialogLayer = function(dialogLayerID){
	    this.getDialogLayer(dialogLayerID).remove();
	};
	
	_Dialog.prototype.showDialogLayer = function(dialogLayerID){
        this.getDialogLayer(dialogLayerID).show().css({
            visibility : 'visible'
        });
    };
	
	_Dialog.prototype.hideDialogLayer = function(dialogLayerID){
        this.getDialogLayer(dialogLayerID).hide();
    };
	
	//---------------------------------------------------------------------------------------------------------
	
	_Dialog.prototype.addArrow = function(){
	    var _this = this;
        this.addDialogLayer('left_arrow', '<div class="dialogNav leftNav">Left</div>', function($dialogLayer){
            $dialogLayer.click(function(){
                _this.fire('nav', 'left'); 
            });            
        }, this.$wrapper);
        this.addDialogLayer('right_arrow', '<div class="dialogNav rightNav">Right</div>', function($dialogLayer){
            $dialogLayer.click(function(){
                _this.fire('nav', 'right'); 
            });            
        }, this.$wrapper);
	};
	
	//---------------------------------------------------------------------------------------------------------    
	
	/**
	 * 添加预定义的对话框按钮。
	 * buttonType  save 
	 */
	_Dialog.prototype.addPredefinedDialogButton = function(buttonType, cb){
	    this.addDialogButton({
	        cls : buttonType,
            text : buttonType.capitalize(),
            handler : cb || Function.empty
	    });
	};
	
	//添加对话框按钮.
	_Dialog.prototype.addDialogButton = function(btnCfg /* or btnCfg Array*/){	    
	    //兼容addDialogButton(buttonType, cb).
	    if(Type.isString(btnCfg)){
	        this.addPredefinedDialogButton(arguments[0], arguments[1]);
	        return;
	    }	    
		var btnCfgArr = $.isArray(btnCfg) ? btnCfg : [ btnCfg ],
			_this = this,
			i = 0,
			len = btnCfgArr.length,			
			btnCfgItem = null,
			dialogToolbar = this.$wrapper.find('.dialogToolbar');
			
		for(; i<len; i++){
			btnCfgItem = btnCfgArr[i];	
			if(!btnCfgItem){
			    continue;
			}
			if(btnCfgItem['props']){
			    var props = String(btnCfgItem['props']).split('|'); 
			    if(props.length > 1){
    			    if(props[0]){
    			        btnCfgItem['cls'] = props[0];
    			    }
    			    if(props[1]){
                        btnCfgItem['text'] = props[1];
                    }
                    if(props[2]){
                        btnCfgItem['cssText'] = props[2];
                    }
                } else {
                    btnCfgItem['cls'] = props[0].lowercaseFirstChar();
                    btnCfgItem['text'] = props[0].uppercaseFirstChar();  
                    btnCfgItem['cssText'] = ''; 
                }
			}		
			dialogToolbar.append(
				$('<button class="{0}" style="{1}" >{2}</button>'.format(
					btnCfgItem['cls'] || btnCfgItem['text'].shrink().lowercaseFirstChar(),
					btnCfgItem['cssText'] || '', 
					btnCfgItem['text']
				)).click( ( function( btnCfgItem ){					
					return function(e){
						if(btnCfgItem['handler']){
							btnCfgItem['handler'].call(_this, $(this), btnCfgItem);
						}
					};
				})( btnCfgItem ))
			);
		}
		return this;
	};
	
	//---------------------------------------------------------------------------------------------------------------------
	
	/**
	 * 添加对话框组件.
     * @param {Object} dialogCmpHtml
     * @param {Object} area : 'body' / 'foot'
     * @param {Object} callback
	 */
	_Dialog.prototype.addDialogCmp = function(dialogCmpHtml, area,  callback){
	    var $dialogCmpHtml = $(dialogCmpHtml),
	        $container = this.$dialogBody;
	    if(area === 'foot'){
	        $container = this.$wrapper.find('.dialogToolbar');
	    }	    
	    $container.append($dialogCmpHtml);
	    lan.parse($dialogCmpHtml);
	    if(callback){	        
	        callback($dialogCmpHtml);
	    }
	    return this;
	};
	
	//---------------------------------------------------------------------------------------------------------------------
	
	//初始化按钮的显示状态.
	_Dialog.prototype.switchDialogButtons = function(btnClsArr){
		var dialogToolbar = this.$wrapper.find('.dialogToolbar');
		dialogToolbar.find('button').hide();
		for( var i = 0,len = btnClsArr.length; i < len; i++ ){
			dialogToolbar.find( 'button.{0}'.format( btnClsArr[i] ) ).show();	
		}
		return this;
	};
	
	//---------------------------------------------------------------------------------------------------------------------
	
	//若Dialog中包含一个form表单，返回该表单中的值.
	_Dialog.prototype.getFormValue = function(){
		var dialogForm = this.$dialogBody.find('form');
		if(ujs.browser.form.validate(dialogForm)){
			return ujs.browser.form.getValues(dialogForm);				
		} else {
			return false;
		}
	};
	
	//-------------------------------------------------------------------
	
	//显示对话框的遮盖层.
	_Dialog.prototype.showMask = function(maskText){
		var dialogMasker = this.$wrapper.find('.dialogMasker');
		if(Type.isNumber(maskText) && parseInt(maskText) <= 1){
            //进度条.
            maskText = [
                '<progress value="{0}"></progress>',
                '<span class="progressValue">{1}%</span>'
            ].join('').format(maskText, parseInt(maskText*100));
        }            
		dialogMasker.find('.dialogProcessingText').html(maskText);
		return dialogMasker.removeClass('hidden');
	};
	
	//隐藏对话框的遮盖层.
	_Dialog.prototype.hideMask = function(){
		this.$wrapper.find('.dialogMasker').addClass('hidden');
		return this;
	};
	
	//-------------------------------------------------------------------
	
	_Dialog.prototype.showCard = function(cardName){
	    var $currentCard = this.getCurrentCard();
	    if($currentCard.attr('card-name') != cardName){
            $currentCard.animate({
                left : '-100%',    
            }, function(){
                $(this).hide();
            });            
            this.getCard(cardName).css({
                left : '100%',
                display:'block'
            }).animate({
               left : 0
            });        
        }
        this.applyCardProps(cardName);
        this.fire('showCard', cardName);
        return this;
	};
	
	_Dialog.prototype.applyCardProps = function(cardName){
	    if(this.config['cards']){
            var cardConfig = this.config['cards'][cardName];
            if(cardConfig){
                if(cardConfig['buttons']){
                    this.switchDialogButtons(cardConfig['buttons']);
                }
                if(cardConfig['title']){
                    this.setTitle(cardConfig['title']);
                }
            }
        }
	};
	
	_Dialog.prototype.hasCard = function(){
	    return !!this.getCardCount();
	};
	
	_Dialog.prototype.getCurrentCard = function(){
	    return this.$wrapper.find('.dialogBody>[card-name]:visible');
	};
	
	_Dialog.prototype.isCurrentCard = function(cardName){
        return this.getCurrentCardName() == cardName;
    };
	
	_Dialog.prototype.getCurrentCardName = function(){
	    return this.getCurrentCard().attr('card-name');
	};
	
	_Dialog.prototype.getCards = function(){
        return this.$wrapper.find('.dialogBody>.card');
    };
	
	_Dialog.prototype.getCard = function(cardName){
	    return this.$wrapper.find('.dialogBody>[card-name={0}]'.format(cardName));
	};
	
	_Dialog.prototype.getCardCount = function(){
	    return this.getCards().size();
	};
	
	//-------------------------------------------------------------------
	
	_Dialog.prototype.getInnerFrame = function(){
        return this.$wrapper.find('iframe').get(0);
	};
	
	//-------------------------------------------------------------------
	
	_Dialog.prototype.getForm = function(){
        var $form = this.$wrapper.find('form');        
        return $form.isExist() ? $form : null;
	};
	
	_Dialog.prototype.getFormData = function(){
	    var $form = this.getForm();
        return $form ? ujs.browser.form.getValues($form) : {};
    };
    
    _Dialog.prototype.initFormData = function(formData){
        var $form = this.getForm();
        $form && ujs.browser.form.setValues($form, formData);
        return this;
    };
	
	_Dialog.prototype.getDialogBodyInnerSize = function(){
	    return {
	        width : this.$dialogBody.innerWidth(),
	        height : this.$dialogBody.innerHeight()
	    };
	};
	
	//-------------------------------------------------------------------
	
	_Dialog.prototype.bubble = function(_bubbleConfig, cb){	    
	    var _this = this;
	    //支持bubble(text, cb);
	    if(Type.isString(_bubbleConfig)){
	        var msg = _bubbleConfig;
	        _bubbleConfig = {
	            text : msg
	        };
	    }
	    //完善bubbleCfg.
	    _bubbleConfig = $.extend({}, _bubbleDefaultConfig, _bubbleConfig);
	    //生成bubble template.
	    switch(_bubbleConfig['type']){
	        case 'tip' :
    	        var bubbleTmp = [
                    '<div class="dialogBubbleWrapper <%=o.type%>">',
                       '<span><%= o.text %></span>',
                       '<span class="closeBtn"></span>',
                   '</div>'
                ];
                break;
            case 'confirm' :
                var bubbleTmp = [
                    '<div class="dialogBubbleWrapper <%=o.type%>">',
                       '<span><%= o.text %></span>',
                       '<a class="dialogBubbleBtn yes" href="#" title="Yes">Yes</a>',
                       '<a class="dialogBubbleBtn no" href="#" title="No">No</a>',
                       '<span class="closeBtn"></span>',
                   '</div>'
                ];
                break;
	    }   
            
        var $bubble = this.$bubble = $(tmpl(bubbleTmp.join(''), _bubbleConfig)); 
        
        //关闭bubble.    
	    $bubble.find('.closeBtn').click(function(){
	        _this.closeBubble(cb);
	    });
	    
	    this.$dialogBody.append($bubble);
	    $bubble.slideDown();
	    
	    switch(_bubbleConfig['type']){
            case 'tip' :
                (function(){
                    _this.closeBubble(cb);
                }).defer(5000);    
                break;
            case 'confirm' :
                $bubble.find('.dialogBubbleBtn.yes').click(function(){
                    _this.closeBubble(cb);
                    _bubbleConfig['onYes'] && _bubbleConfig['onYes'](_this);
                    return false;
                });
                $bubble.find('.dialogBubbleBtn.no').click(function(){
                    _this.closeBubble(cb);
                    _bubbleConfig['onNo'] && _bubbleConfig['onNo'](_this);
                    return false;
                });
                break;
        }  
	};
	
	_Dialog.prototype.closeBubble = function(cb){
	    if(this.$bubble){     
    	    this.$bubble.slideUp(function(){
                $(this).remove();
                cb && cb(_this);
            });
        }
    };
	
	//-------------------------------------------------------------------
	
	_Dialog.prototype.showToolbar = function(){
	    this.$dialogBody.css('height', 'calc(100% - 95px)');
	};
	
	_Dialog.prototype.hideToolbar = function(){
        this.$dialogBody.css('height', 'calc(100% - 58px)');
    };
    
    //-------------------------------------------------------------------
    
    /**
     * 获取对话框实例，并显示之. 
     * @param {Function} concreteDialogConstructor
     * @param {Object} config
     */
    _Dialog.get = function(concreteDialogConstructor, config){
        var dialogObj = null;
        if(Type.isFunction(concreteDialogConstructor)){
            dialogObj = new concreteDialogConstructor(config || {});
        } else if(Type.isObject(concreteDialogConstructor) && Type.isUndefined(config)){
            config = concreteDialogConstructor;
            dialogObj = new _Dialog(config);
        }
        return dialogObj ? dialogObj.show() : null;        
    };
    
	//-------------------------------------------------------------------

	ujs.define('Dialog', 'ujs.ui', function(){
        return _Dialog;
    });    
})($, document);